<!DOCTYPE html>
<html lang="<?php echo Yii::app()->language; ?>">
<head>
	<base href="<?php echo Yii::app()->request->baseUrl; ?>/static/" />
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="cache-control" content="public, max-age=604800">
    <meta http-equiv="Pragma" CONTENT="no-cache">
	<meta http-equiv="Expires" CONTENT="-1">
	<title><?php echo CHtml::encode($this->pageTitle); ?></title>
	<link rel="stylesheet" type="text/css" href="<?php echo MINIFY_URL; ?>?g=css&ver=1.0" media="screen" /> 
	<script type="text/javascript" src="<?php echo MINIFY_URL; ?>?g=js&ver=1.0"></script>
</head>
<body>
<!-- Begin page content -->
<div class="container">
	<div class="logo">
    	<a href="/"><img src="img/logo.png?ver=1.0" class="img-responsive"></a>
    </div>
    <nav class="navbar navbar-default" role="navigation">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              <a class="navbar-brand" href="/" title="<?php echo Yii::t('helpdesk','Home'); ?>"><i class="fa fa-home"></i></a>
            </div>
            
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                <li <?php if(Yii::app()->controller->id == 'site' && (in_array(Yii::app()->controller->action->id, array('documents', 'viewdocument')))): ?>class="active"<?php endif; ?>><a href="/documents.html"><?php echo Yii::t('helpdesk','Documents'); ?></a></li>
                <li <?php if(Yii::app()->controller->id == 'site' && Yii::app()->controller->action->id == 'faqs'): ?>class="active"<?php endif; ?>><a href="/faqs.html"><?php echo Yii::t('helpdesk','FAQs'); ?></a></li>
                
                <!-- [TICKETS] -->
                <?php $arrMenuDepts = HelpDesk::getInstance()->getDepts(false); ?>
                <li class="<?php if(!empty($arrMenuDepts)): ?>dropdown<?php endif;?> <?php if(Yii::app()->controller->id == 'tickets'): ?>active<?php endif; ?>">
                	<!--<span class="alert">10+</span>-->
                    <a <?php if(!empty($arrMenuDepts)): ?>href="javascript:void(0);"  class="dropdown-toggle" data-toggle="dropdown"<?php else: ?>href="/tickets.html"<?php endif; ?>><?php echo Yii::t('helpdesk','Support Tickets'); ?> <b class="caret"></b></a>
                	<?php if(!empty($arrMenuDepts)): ?>
                    <ul class="dropdown-menu">
                    	<?php foreach($arrMenuDepts as $R): ?>
                    	<li><a href="/tickets/<?php echo Utils::uri_encode($R['category_name']).'.'.$R['category_id']; ?>.html"><?php echo $R['category_name']; ?></a></li>
                        <?php endforeach; ?>
                    </ul>
                    <?php endif;?>
                </li>
				
                <!-- [LOGIN & MY ACCOUNT] -->
				<?php if(Yii::app()->user->isGuest): ?>
                <li><a href="/auth/login"><?php echo Yii::t('helpdesk','Login'); ?></a></li>
                <?php else: ?>
                <li <?php if(Yii::app()->controller->id == 'user' && Yii::app()->controller->action->id == 'index'): ?>class="active"<?php endif; ?>><a href="/my-account.html"><?php echo Yii::t('helpdesk','My Account'); ?></a></li>
                
                <!-- [ADMIN] -->
				<?php if(Yii::app()->user->hasPermission('helpdesk-manage-contents') || Yii::app()->user->hasPermission('helpdesk-manage-users') ||  Yii::app()->user->hasPermission('helpdesk-manage-settings')): ?>
                <!-- start admin menu -->
                <li class="dropdown <?php if(Yii::app()->controller->id == 'admin'): ?>active<?php endif; ?>">
                  <a href="/admin" class="dropdown-toggle" data-toggle="dropdown"><?php echo Yii::t('helpdesk','Admin'); ?> <b class="caret"></b></a>
                  <ul class="dropdown-menu">
                  	<?php if(Yii::app()->user->hasPermission('helpdesk-manage-contents')): ?>
                  	<li><a href="/admin/documents"><?php echo Yii::t('helpdesk','Manage Content'); ?></a></li>
                    <?php endif; ?>
                    <?php if(Yii::app()->user->hasPermission('helpdesk-manage-users')): ?>
                    <li><a href="/admin/members"><?php echo Yii::t('helpdesk','Manage Users'); ?></a></li>
                    <?php endif; ?>
                    <?php if(Yii::app()->user->hasPermission('helpdesk-manage-reports')): ?>
                    <li><a href="/admin/dashboard"><?php echo Yii::t('helpdesk','Reports'); ?></a></li>
                    <?php endif; ?>
                    <?php if(Yii::app()->user->hasPermission('helpdesk-manage-settings')): ?>
                    <li><a href="/admin/departments"><?php echo Yii::t('helpdesk','Settings'); ?></a></li>
                    <?php endif; ?>
                  </ul>
                </li>
                <!-- end menu admin -->
                <?php endif; ?>
                
                <!-- [LOGOUT] -->
                <li><a href="/auth/logout"><i class="fa fa-sign-out fa-lg"></i> <?php echo Yii::t('helpdesk','Logout'); ?></a></li>
                <?php endif; ?>
              </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>
	<section>
    	<?php if(!Yii::app()->user->isGuest): ?><div style="text-align:right; float:right;">
        	<?php $profile = Users::getInstance()->getProfile(Yii::app()->user->id); ?>
            <?php if(!empty($profile['profile_image'])): ?>
            <img class="avatar" src="<?php  echo UPLOADS_URL.'/'.$profile['profile_image']; ?>">
            <?php else: ?>
        	<i class="fa fa-user fa-sm fa-border"></i> 
            <?php endif; ?>
            <strong><?php echo Yii::app()->user->fullname; ?></strong></div>
		<?php endif; ?>
    	<?php echo $content; ?>
    </section>
    <div class="footer">    	
        <select name="_lang" id="_lang" class="col-md-3" style="float:right;">
            <option value='vi' data-image="./img/vn.gif" <?php if(Yii::app()->session['_lang'] == 'vi'): ?>selected<?php endif; ?>>Tiếng Việt</option>
            <option value='en' data-image="./img/gb.gif" <?php if(Yii::app()->session['_lang'] == 'en'): ?>selected<?php endif; ?>>English (UK)</option>
        </select><br><br>
        <p  style="font-style:italic; font-size: 12px; text-align: right;">
        	<a href="<?php echo Yii::app()->request->baseUrl.'/docs/HR_Helpdesk_User_Guide.pdf'; ?>" target="_blank"><?php echo Yii::t('helpdesk','User guide'); ?></a><br>
            Help Desk System.<br>
			<?php echo Yii::t('helpdesk','Developed by'); ?> IT@DatVietVAC &copy;
        </p>
        
    </div>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
	$(".tt").tooltip();
	try {
		$("#_lang").msDropdown();
		$("#_lang").change(function(){
			$.ajax({
				type: "GET",
				url: document.URL,
				data: { _lang: this.value }
			})
			.done(function( msg ) {
				location.reload(true);
			});
		});
	} catch(e) {
		//keep silent
		//alert(e.message);
	}
});
</script>
</html>
